<include file="Public:header" />
<load href="__ROOT__/css/demo_menu/jquery.treeview.css" />
<load href="__ROOT__/js/demo_menu/jquery.treeview.js" />
<script type="text/javascript">
$(function() {
        var body=$('[id=main]');  //定义根对象
        var list=$('[id=tree]'); //伸缩列表对象
        
        $("#tree").treeview({
                collapsed: true,
                animated: "medium",
                control:"#sidetreecontrol",
                persist: "location"
        });

        
        $(document).ready(function(){
            //获取并解释已经存在的父级部门分类列表
            $.getJSON(app_url+"/bumen-get_parentlist","",function(data){
                body.find('[name=tishi]').remove();
                $.each(data,function(i,c){
                    var parent_list={
                        'bm_id':c.bm_id,
                        'bm_name':c.bm_name,
                        'bm_main':c.bm_main
                    };
                    //alert(parent);
                  display_list(parent_list,list);
//    //                });
                });
            });
        });


        //父级列表显示函数
    function display_list(parent_list,hh){
        var li=$('<li></li>');
        var img=$('<img src="'+base_url+'/images/add.gif"></img>');
        var z_img=$('<img src="'+base_url+'/images/z_add.gif"></img>');
        z_img.hide();
        var ul=$('<ul></ul>');
        var href=$('<a href="'+app_url+'/bumen-edit_bm-id-'+parent_list.bm_id+'" target="bm_right"></a>').append(parent_list.bm_name);
        $.getJSON(app_url+"/bumen-get_bumenlist-id-"+parent_list.bm_id,"",function(data){
                if(data==0){
                    img.remove();
                }
            });
        href.click(function(){
            ul.empty();
            $.getJSON(app_url+"/bumen-get_bumenlist-id-"+parent_list.bm_id,"",function(data){
                if(data==0){
                    img.remove();
                }
                $.each(data,function(i,c){
                    var info_list={
                        'bm_id':c.bm_id,
                        'bm_name':c.bm_name,
                        'bm_main':c.bm_main
                    };
                    //alert(info_list.bm_name);
                    img.remove();
                    z_img.show();
                  display_bmlist(info_list,ul);
                });
            });
        });
        li.append(img).append(z_img).append(href).append(ul).appendTo(hh);
    }



        //次级列表显示函数
    function display_bmlist(parent_list,hh){
        var img=$('<img src="'+base_url+'/images/add.gif"></img>');
        var z_img=$('<img src="'+base_url+'/images/z_add.gif"></img>');
        z_img.hide();
        var tishi=$('<li></li>').append('数据加载中...请稍后...');
        var li=$('<li></li>');
        var ul=$('<ul></ul>');
        var href=$('<a href="'+app_url+'/bumen-edit_bm-id-'+parent_list.bm_id+'" target="bm_right"></a>').append(parent_list.bm_name);
        $.getJSON(app_url+"/bumen-get_bumenlist-id-"+parent_list.bm_id,"",function(data){
                if(data==0){
                    img.remove();
                }
        });
        href.click(function(){
            ul.empty();
            ul.append(tishi);
            $.getJSON(app_url+"/bumen-get_bumenlist-id-"+parent_list.bm_id,"",function(data){
                if(data==0){
                    img.remove();
                }
                $.each(data,function(i,c){
                    var info_list={
                        'bm_id':c.bm_id,
                        'bm_name':c.bm_name,
                        'bm_main':c.bm_main
                    };
                    img.remove();
                    z_img.show();
                    //alert(info_list.bm_name);
                  display_bmlist(info_list,ul);
                });
                
            });
            tishi.remove();
        });
        li.append(img).append(z_img).append(href).append(ul).appendTo(hh);
    }

    
});
</script>
<div id="main">
<div id="sidetree">
<!--    <div id="sidetreecontrol">&nbsp;<a href="?#">关闭所有</a> | <a href="?#">展开所有</a></div>-->
<ul id="tree">
    {$list}
	<li name="tishi">
            数据加载中...请稍后...
	</li>
	
	
<!--	<li><a href="#"><strong>城市服务</strong></a>
	<ul>
		<li><a href="#">1</a>
                    <ul>
                            <li><a href="#">2</a></li>
                            <li><a href="#">2</a></li>
                            <li><a href="#">2</a></li>
                    </ul>
		</li>
        </ul>
        </li>-->
                <!--
	
		
		
		<li><a href="?#">sss</a>
		<ul>
			<li><a href="?/building_inspections/index.cfm">Building Inspections</a>
			<ul>
				<li><a href="?/building_inspections/builder_forums.cfm">Builder Forums</a></li>
				<li><a href="?/building_inspections/contact_us.cfm">Contact Us</a></li>
				<li><a href="?/building_inspections/contractor_notices.cfm">Contractor Notices</a></li>
				<li><a href="?/building_inspections/inspector_guidelines.cfm">Inspector Guidelines</a></li>
				<li><a href="?/building_inspections/links.cfm">Links</a></li>
				<li><a href="?/building_inspections/statistics_2007.cfm">Statistics</a>
				<ul>

					<li><a href="?/building_inspections/statistics_2006.cfm">Statistics 2006</a>
					<ul>
					<li><a href="?/building_inspections/statistics_2006.cfm">Statistics 2006</a></li>
					<li><a href="?/building_inspections/statistics_2005.cfm">Statistics 2005</a></li>
					</ul></li>
					<li><a href="?/building_inspections/statistics_2005.cfm">Statistics 2005</a></li>
				</ul>
				</li>
			</ul>
			</li>
			<li><a title="City Infrastructure" href="?/building_development/city_infrastructure/index.cfm">City Infrastructure</a>
			<ul>

				<li><a href="?/building_development/city_infrastructure/roadway_improvement.cfm">Roadway Improvement</a></li>
				<li><a href="?/building_development/city_infrastructure/traffic.cfm">Traffic</a></li>
				<li><a href="?/building_development/city_infrastructure/transportation_planning.cfm">Transportation &amp; Infrastructure Planning</a></li>
				<li><a href="?/building_development/city_infrastructure/water_sewer_construction.cfm">Water &amp; Sewer Construction</a></li>

			</ul>
			</li>
			<li><a title="Commercial/Industrial Development" href="?/building_development/commercial_industrial_development/index.cfm">Commercial / Industrial / Multi-Family Development</a>
			<ul>
				<li><a title="Call Before You Dig" href="?/building_development/commercial_industrial_development/call_before_you_dig.cfm">Call Before You Dig</a></li>
				<li><a title="New Development" href="?/building_development/commercial_industrial_development/new_development.cfm">New Development</a></li>
				<li><a title="Existing Development" href="?/building_development/commercial_industrial_development/existing_development.cfm">Existing Development</a></li>
				<li><a title="Signage" href="?/building_development/commercial_industrial_development/signage.cfm">Signage</a></li>
				<li><a title="Notice of Development" href="?/building_development/planning/notice_of_development/notice_of_development.cfm">Notice of Development</a></li>
				<li><a title="Appeals" href="?/public_meetings/appeals/index.cfm">Appeals</a></li>
				<li><a title="Customer Feedback" href="?/building_development/commercial_industrial_development/customer_feedback.cfm">Customer Feedback</a></li>
				<li><a title="Certificate of Compliance" href="?/building_development/commercial_industrial_development/certificate_of_compliance.cfm">Certificate of Compliance</a></li>
				<li><a title="Permit Applications &amp; Forms" href="?/building_development/commercial_industrial_development/permit_applications_forms.cfm">Permit Applications &amp; Forms</a></li>
				<li><a title="Fees" href="?/building_development/commercial_industrial_development/fees.cfm">Fees</a></li>
			</ul>
			</li>
			<li> This links to an empty content page (25 Sept 2007)  <a title="Residential Development" href="?/building_development/residential_development/index.cfm">Residential Development</a>
			<ul>
				<li><a title="Call Before You Dig" href="?/building_development/residential_construction/building_permit_requirements.cfm">Building Permit Requirements</a></li>
				<li><a title="New Development" href="?/building_development/residential_construction/new_homes.cfm">New Homes</a></li>
				<li><a title="Existing Development" href="?/building_development/residential_construction/basements.cfm">Basements</a></li>
				<li><a title="Signage" href="?/building_development/commercial_industrial_development/call_before_you_dig.cfm">Call Before You Dig</a></li>
				<li><a title="Decks" href="?/building_development/residential_development/decks.cfm">Decks</a></li>
				<li><a title="Detached Garages or Accessory Building" href="?/building_development/residential_development/detached_garages_or_accessory_building.cfm">Detached Garages or Accessory Building</a></li>
				<li><a title="Grading" href="?/building_development/residential_development/grading.cfm">Grading</a></li>
				<li><a title="Fences" href="?/building_development/residential_development/fences.cfm">Fences</a></li>
				<li><a title="Applications, Permits &amp; Checklists" href="?/building_development/residential_development/applications_permits_checklists.cfm">Applications, Permits &amp; Checklists</a></li>
				<li><a title="Certificate of Compliance" href="?/building_development/commercial_industrial_development/certificate_of_compliance.cfm">Certificate of Compliance</a></li>
				<li><a title="Fees" href="?/building_development/residential_development/fees.cfm">Fees</a></li>
				<li><a title="Notice of Development" href="?/building_development/planning/notice_of_development/notice_of_development.cfm">Notice of Development</a></li>
				<li><a title="Street Addresses for New Construction" href="?/gis/index.cfm">Street Addresses for New Construction</a></li>
			</ul>
			</li>
		</ul>
		</li>
		<li><a href="?/community_safety/index.cfm">Community Safety</a>
		<ul>
			<li><a href="?/disaster_services/index.cfm">Disaster Services</a></li>

			<li><a href="?/emergency_services/index.cfm">Emergency Services</a></li>
			<li><a href="?/municipal_enforcement/index.cfm">Municipal Enforcement</a></li>
			<li><a href="?/rcmp/index.cfm">Royal Canadian Mounted Police</a>
			<ul>
				<li><a title="Community Partnership Programs" href="?/rcmp/community_partnership_programs.cfm">Community Partnership Programs</a></li>
				<li><a title="Traffic Services" href="?/rcmp/traffic_services.cfm">Traffic Services</a></li>

			</ul>
			</li>
		</ul>
		</li>
		<li><a href="?/community_services/index.cfm">Community Services</a>
		<ul>
			<li><a href="?/directories/community_directory/index.cfm">Community Directory</a></li>
			<li><a href="?/calendars/index.cfm">Community Calendar</a></li>

		</ul>
		</li>
		<li><a href="?/engineering/index.cfm">Engineering Services </a></li>
		<li><a href="?/finance/index.cfm">Finance</a></li>
		<li><a href="?/gis/index.cfm">Maps (GIS)</a></li>
		<li><a href="?/parks/parks_recreation.cfm">Parks &amp; Recreation</a></li>

		<li><a href="?/public_works/index.cfm">Public Works</a></li>
		<li><a href="?/recycling_waste/index.cfm">Recycling, Waste &amp; Composting</a>
		<ul>
			<li><a href="?/environmental_services/index.cfm">Environmental Services </a></li>
		</ul>
		</li>

		<li><a href="?/social_planning/index.cfm">Social Planning</a></li>
		<li><a href="?/taxation/index.cfm">Taxation</a></li>
		<li><a href="?/transit/index.cfm">Transit</a></li>
		<li><a href="?/utilities/index.cfm">Water &amp; Sewer (Utilities)</a></li>
	</ul>
	</li>-->

	

</ul>
</div>

</div>
</body>
</html>
